package com.huatai.datacenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huatai.common.util.StringUtil;
import com.huatai.datacenter.entity.datadesensitization.DesensitizationApplyEntity;
import com.huatai.datacenter.mapper.DesensitizationApplyMapper;
import com.huatai.datacenter.service.DesensitizationApplyService;
import org.springframework.stereotype.Service;

/**
 * @author gusiyi
 * @version 1.0
 * @className DesensitizationApplyServiceImpl
 * @description 描述：
 * @date 2023/6/12 16:55
 */
@Service
public class DesensitizationApplyServiceImpl extends ServiceImpl<DesensitizationApplyMapper, DesensitizationApplyEntity> implements DesensitizationApplyService {

	@Override
	public Page<DesensitizationApplyEntity> getDesensitizationApplyList(DesensitizationApplyEntity desensitizationApplyEntity) {
		LambdaQueryWrapper<DesensitizationApplyEntity> applyQuery = Wrappers.lambdaQuery();
		applyQuery
			.eq(DesensitizationApplyEntity::getDeleted,false)
			.like(StringUtil.isNotBlank(desensitizationApplyEntity.getDesensitizationName()), DesensitizationApplyEntity::getDesensitizationName,desensitizationApplyEntity.getDesensitizationName());
		return page(new Page<>(desensitizationApplyEntity.getPageIndex(), desensitizationApplyEntity.getPageSize()), applyQuery);
	}

	@Override
	public boolean bindApply(DesensitizationApplyEntity desensitizationApplyEntity) {
		return save(desensitizationApplyEntity);
	}
}
